package com.example.my_self_view.viewdrag

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.example.my_self_view.R
import com.example.my_self_view.databinding.ActivityViewDragBinding

class ViewDragActivity: AppCompatActivity() {

    private lateinit var mBinding: ActivityViewDragBinding
    private val mItems = arrayListOf<String>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityViewDragBinding.inflate(layoutInflater)
        setContentView(mBinding.root)


        for (i in 0 until 200) {
            mItems.add("i -> $i")
        }

        mBinding.listView.adapter = object : BaseAdapter(){
            override fun getCount(): Int {
                return mItems.size
            }

            override fun getItem(position: Int): Any? {
                return null
            }

            override fun getItemId(position: Int): Long {
                return 0
            }

            override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
                val cv = LayoutInflater.from(this@ViewDragActivity).inflate(R.layout.item_tv, parent, false) as TextView
                cv.text = mItems[position]
                return cv
            }
        }

    }

}